<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增律师信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-lawyerInfo-add">
            <div class="form-group">
                <label class="col-sm-3 control-label">用户：</label>
                <div class="col-sm-8">
                    <select name="userId" id="userId" class="form-control m-b" th:with="userList=${userList}" onchange="showDetail();">
                        <option th:each="user : ${userList}" th:text="${user.userName}" th:value="${user.userId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">头像：</label>
                <div class="col-sm-8">
                    <img name="headPortrait" id="headPortrait" src=""/> 
<!--                     <input name="headPortrait" th:field="*{headPortrait}" class="form-control" type="text"> -->
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">律师姓名：</label>
                <div class="col-sm-8">
                    <input name="lawyerName" id="lawyerName" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">律师执业证件号：</label>
                <div class="col-sm-8">
                    <input name="lawyerCertificateNo" id="lawyerCertificateNo" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地址：</label>
                <div class="col-sm-8">
                    <input name="address" id="address" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">手机号：</label>
                <div class="col-sm-8">
                    <input name="mobile" id="mobile" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <input name="email" id="email" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所在律师事务所名称：</label>
                <div class="col-sm-8">
                    <input name="lawFirmName" id="lawFirmName" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">律师介绍：</label>
                <div class="col-sm-8">
                    <input name="lawyerIntroduce" id="lawyerIntroduce" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">标签：</label>
                <div class="col-sm-8">
                    <textarea name="label" class="form-control" placeholder="多项逗号分隔"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">金点子服务价格：</label>
                <div class="col-sm-8">
                    <input name="price" class="form-control" type="number">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "business/lawyerInfo"
        showDetail();
        $("#form-lawyerInfo-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-lawyerInfo-add').serialize());
            }
        }
        
        function showDetail(){
            $.ajax({
                type: "post",
                url: prefix+ "/editDetail",
                data: {userId:$("#userId").val()},
                dataType: "json",
                success: function(data){
                    $("#headPortrait").attr("src", data.headPortrait);
                    $("#lawyerName").val(data.userName);
                    $("#lawyerCertificateNo").val(data.lawyerCertificateNo);
                    $("#address").val(data.address);
                    $("#mobile").val(data.mobile);
                    $("#email").val(data.email);
                    $("#lawFirmName").val(data.lawFirmName);
                }
            });
        }
    </script>
</body>
</html>